﻿//This file is part of Search Engine by Tomasz Kusienicki.
// 
//This Search Engine is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//any later version.
// 
//Foobar is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
// 
//You should have received a copy of the GNU General Public License
//on <http://www.gnu.org/licenses/>.

using System.Windows.Forms;

namespace AdminApp1.Common
{
    /// <summary>
    /// View base
    /// </summary>
    public abstract class ViewBase<TView, TPresenter> : Form
        where TView : ViewBase<TView, TPresenter>
        where TPresenter : PresenterBase<TView, TPresenter>
    {
        #region Presenter { get; set; }
        private TPresenter _presenter;
        public TPresenter Presenter
        {
            get { return _presenter; }
            internal set
            {
                _presenter = value;
                OnPresenterSet();
            }
        }
        #endregion

        #region (virtual) OnPresenterSet
        protected virtual void OnPresenterSet(){ }
        #endregion
    }

    /// <summary>
    /// View base
    /// </summary>
    public abstract class ViewBase<TView, TPresenter, TModel> : ViewBase<TView, TPresenter>
        where TView : ViewBase<TView, TPresenter, TModel>
        where TPresenter : PresenterBase<TView, TPresenter, TModel>
        where TModel : ModelBase<TModel>
    {
        #region Model { get; set; }
        private TModel _model;
        public TModel Model
        {
            get { return _model; }
            internal set
            {
                _model = value;
                OnModelSet();
            }
        }
        #endregion

        #region (virtual) OnModelSet
        protected virtual void OnModelSet(){ }
        #endregion
    }
}